package databinding.demo.ui;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import databinding.demo.R;
import databinding.demo.databinding.ActivityBindLambdaBinding;
import databinding.demo.model.EmployeeInfo;
import databinding.demo.utils.LogUtils;

/**
 * Created by dengdayi
 * Date: 2017/03/30 09：56
 * 高级篇-Lambda表达式
 */

public class BindLambdaActivity extends AppCompatActivity {
    ActivityBindLambdaBinding mBinding;
    EmployeeInfo employeeInfo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_bind_lambda);
        employeeInfo = new EmployeeInfo("http://wmtp.net/wp-content/uploads/2016/07/1010689200fa918b241.jpg", "张三");
        mBinding.setEmployeeInfo(employeeInfo);
        mBinding.setPresenter(new Presenter());
    }

    public class Presenter {
        public void onEmployeeClick(EmployeeInfo info) {
            LogUtils.getInstance().logE("onEmployeeClick info : " + info.toString());
        }

        public void onEmployeeLongClick(EmployeeInfo info, Context context) {
            Toast.makeText(context, "onEmployeeLongClick info : " + info.toString(), Toast.LENGTH_LONG)
                    .show();
        }

//        public void onFocusChanged(EmployeeInfo info) {
//            LogUtils.getInstance().logE("onFocusChange info : " + info.toString());
//        }
    }
}
